Skip to content

CFM-31_Enrollment_Flows_enable_people_picker_for_self_service #337

Conversation

Ioannis
Copy link
Contributor

@Ioannis Ioannis commented Sep 13, 2025

Enable people picker functionality as an AttributeCollector configuration

@Ioannis Ioannis requested a review from arlen September 13, 2025 13:54
@Ioannis Ioannis force-pushed the CFM-31_Enrollment_Flows_enable_people_picker_for_self_service branch from 0b5171b to ac177db Compare September 13, 2025 13:58
@Ioannis
Copy link
Contributor Author

Ioannis commented Sep 13, 2025

Previous Pull Request. It contains the review comments.

Copy link
Contributor

@arlen arlen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@arlen arlen merged commit 1d18bdb into COmanage:develop Sep 15, 2025
@Ioannis Ioannis deleted the CFM-31_Enrollment_Flows_enable_people_picker_for_self_service branch September 15, 2025 17:29
Comment on lines +439 to +463
$petitionId = (int)$request->getQuery('petition_id');
// We need to check if this is part of an Enrollment Flow
$Petitions = $this->fetchTable('Petitions');

// Pull the Petition to find its CO
$petition = $Petitions->get(
$petitionId,
contain: ['EnrollmentFlows' => ['EnrollmentFlowSteps']]
);

// We need to check the Petitioner Authorization.
$hasAuthorizedUser = $petition->enrollment_flow->authz_type == EnrollmentAuthzEnum::AuthUser
? !empty($auth['external']['user']) : true;

foreach ($petition->enrollment_flow->enrollment_flow_steps as $step) {
if ($step->plugin == 'CoreEnroller.AttributeCollectors') {
$AttributeCollectors = $this->fetchTable('CoreEnroller.AttributeCollectors');
$attributeCollectorsRecord = $AttributeCollectors->find()
->where(['enrollment_flow_step_id' => $step->id])
->contain(['EnrollmentAttributes'])
->first();

$mode = $hasAuthorizedUser && $attributeCollectorsRecord->enable_person_find ? 'yes' : 'no';
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of special logic for an API controller. While we can probably leave the outermost test (if(People && pick && petition_id)) in place until we have more use cases to refactor, the actual logic of whether or not the PeoplePicker is enabled should go in PetitionsTable. Or really in EnrollmentFlowsTable, but since we have a Petition ID as context here, and there is a similar function PetitionsTable::isApproverForFlow() already, PetitionsTable::isPersonFindEnabled() probably makes more sense.

Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants